<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <style>

    </style>
</head>

<body>
    <div id="app">
    </div>
</body>
<script>
    let token = '123abc'
    let obj = {
        name: '123',
        age: 18
    }

    //存储操作
    localStorage.setItem('token', token)
    localStorage.setItem('obj', JSON.stringify(obj))

    //取出操作
    let data = JSON.parse(localStorage.getItem('obj'))
    console.log(data)

    //清除
    //localStorage.clear(); //删全部
    //localStorage.removeItem('token') //删某一个

    // localStorage 永久存储
    // 1. 除非是主动删除，不然是不会自动删除的
    // 2. 一般浏览器存储的大小是5M
    // 3.value值是对象时如果不转换成JSON字符串，会自动调用value.toString()后存进去
    // 4.存进去是JSON字符串时，取出来记得转换
</script>

</html>